<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/commons/meta.jsp"%>
<html  style="background: #ffffff; ">
	<head>
		<title>${title}</title>
		<link rel="stylesheet" href="${ctx }/static/styles/login/Global.css" />
		<link rel="stylesheet" href="${ctx }/static/styles/login/admin_login.css" />
	</head>
	<body onload="init();">
		 <!-- admin_login 后台登陆 -->
	    <form id="loginForm" name="loginForm" onsubmit="javascript:return false;"  action="${ctx}/login/login"  method="post">
	    	 <div class="admin_login">
		        <ul>
		            <li style="height:30px;padding:0px;"><p class="prompt" id="prompt">${prompt }</p></li>
		            <li>
		                <label for="">用&nbsp;&nbsp;户&nbsp;&nbsp;名：</label>
		                <input type="text" value="admin" id="username" name="username" style="background-color: #fff"/>
		            </li>
		            <li>
		                <label for="">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：</label>
		                <input type="password" value="111111" id="password" style="background-color: #fff"/>
		                <input type="hidden" value="" id="relpwd" name="password"/>
		            </li>
		            <li style="margin-top: 10px;" >
		                <input type="submit" value="" id="submit_btn" class="admin_login_btn" />
		                <img id="installImg" class="control_img" src="${ctx }/static/images/login/control_install.png" /><!--隐藏安装控件提示-->
					    <img id="updateImg" class="control_img" src="${ctx }/static/images/login/control_update.png" /><!--隐藏升级控件提示-->
		            </li>
		        </ul>
		    </div>
	    </form>
        <!-- main @end -->
    <!-- login @end -->
    <!-- js -->
	<script type="text/javascript" src="${ctx}/static/scripts/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="${ctx}/static/scripts/common.js"></script>
 	<script type="text/javascript" src="${ctx}/static/scripts/md5.js"></script>
 	<object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0> 
		<embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0 pluginspage="${ctx }/static/widgets/lodop/install_lodop32.exe"></embed>
	</object>
	<script type="text/javascript" src="${ctx}/static/widgets/lodop/LodopFuncs.js"></script>
	<script type="text/javascript">
		$(function(){
			$(".admin_login ul li input[type='text']").focus(function(){
				$(this).addClass("current");
				if(this.defaultValue == this.value){
					this.value = "";
				}
			});
			
			$(".admin_login ul li input[type='text']").blur(function(){
				$(this).removeClass("current");
				if("" == this.value){
					this.value = this.defaultValue
				}
			});
			
			$(".admin_login ul li input[type='password']").focus(function(){
				$(this).addClass("current");
				if(this.defaultValue == this.value){
					this.value = "";
				}
			});
			
			$(".admin_login ul li input[type='password']").blur(function(){
				$(this).removeClass("current");
				if("" == this.value){
					this.value = this.defaultValue
				}
			});
			checkLodop();
		});
	    function init(){
	    	//当session失效时退出框架页到登陆页
	    	if(window.top!=window.self)
	    		window.top.location.href=this.location.href;
	    		
	    	var userName = document.getElementById("username");
			var password = document.getElementById("password");
			var yzm = document.getElementById("yzm");
			
			userName.value = '${username}';
			userName.focus();
			
			$("#submit_btn").click(function(){
				if(isEmpty(userName.value)){
					showInfo("用户名不能为空！");
					userName.focus();
					return;
				}
				if(isEmpty(password.value)){
					showInfo("密码不能为空！");
					password.focus();
					return;
				}
				showInfo("正在登录...");
				document.getElementById("relpwd").value = hex_md5(password.value);
				document.forms[0].submit();
			});
			
			$("#submit_btn").click();
			if('${promt}' != ''){
				showInfo('${promt}');
			}
		}
		
		function showInfo(msg){
			$("#prompt").html(msg);
			$("#prompt").show();
		}
		
		//校验打印控件
		function checkLodop(){
			var isIE	 = (navigator.userAgent.indexOf('MSIE')>=0) || (navigator.userAgent.indexOf('Trident')>=0);
		    var is64IE  = isIE && (navigator.userAgent.indexOf('x64')>=0);
		    var tipTitle = "点击下载最新版" + lodopVersion; 
			try{
				var LODOP = getLodop2(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
			     //=====判断Lodop插件是否安装过，没有安装或版本过低就提示下载安装:==========
			     if ((LODOP==null)||(typeof(LODOP.VERSION)=="undefined")) {
		             if (navigator.userAgent.indexOf('Chrome')>=0)
		                 tipTitle += "如果此前正常，仅因浏览器升级或重安装而出问题，需重新安装";
		             if (navigator.userAgent.indexOf('Firefox')>=0)
		                 tipTitle += "注意：如曾安装过Lodop旧版附件npActiveXPLugin,请在【工具】->【附加组件】->【扩展】中先卸它";
		             if (is64IE) 
		             	 downClick($("#installImg"), "64");
	             	 else if (isIE)   
	             		 downClick($("#installImg"), "32");
             		 else
		                 downClick($("#installImg"), "32");
		             
		             $("#installImg").show();
	             	 $("#installImg").attr("title", tipTitle);
			     }else if (LODOP.VERSION < lodopVersion) {
		            if (is64IE)
		             	downClick($("#updateImg"), "64");
		           	else if (isIE) 
		             	downClick($("#updateImg"), "32");
		           	else
		             	downClick($("#updateImg"), "32");
		    	    
		    	    $("#updateImg").show();
		    	    $("#updateImg").attr("title", tipTitle);
			     };
			}catch(e){
				if (is64IE) 
             		downClick($("#installImg"), "64");
           		else
                	downClick($("#installImg"), "32");
                
				$("#installImg").show();
				$("#installImg").attr("title", tipTitle);
			}
		}
		//添加下载点击事件
		function downClick(obj,browserVersion){
			obj.click(function(){ downLodop(browserVersion) });
		}
		//下载打印控件
		function downLodop(browserVersion){
			window.open("${ctx}/static/widgets/lodop/install_lodop"+ browserVersion +".exe");
		}
		
		//回车登陆事件
		document.onkeydown = keyKistener;
		function keyKistener(e){
			e = e ? e:event;
			if(e.keyCode == 13){
				//var loginBtn = document.getElementById("submit_btn");
				//loginBtn.click();
			}
		}
		
    </script>
    <!-- js @end -->
	</body>
</html>